<template>
  <div id="permissions">
    <!-- <k-header headTitle="设置权限" goBack="true" rightTitle="新增" @rightClick="ump"></k-header> -->
    <header class="site-header clearfix" :class="headIos?'side-fixd-ios':'side-fixed'">
      <a href="javascript:;" @click="goBack" class="go-back">
        <i></i>
      </a>
      <a href="javascript:;" @click='ump' class="go-back go-new">新增</a>
      <h1 >权限设置</h1>
    </header>
    <div class='permisslist' :class="headIos?'side-ios':'side-fixeds'">
      <div class="enquiries">
        <input autofocus="autofocus" class="archieve_input _input" placeholder="姓名查询" v-model="seachname" />
        <img class="archieve_img" src="../../../assets/img/reference/report-center-glass.png"/>
        <div class="seachtn" @click="seachnames">搜索</div>
      </div>
    </div>
    <div class="permibox">
      <ul>
        <li v-for="permislis in permisli" :key="permislis.id" @click="edits(permislis.memberId)">
          <div class="perminame">{{ permislis.realName }}</div>
          <div class="permintime">{{ permislis.updateTime | fromdate }}</div>
          <div class="edits">
            <span>编辑</span>
            <i></i>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>
<style scoped>
  ul,li {
    list-style: none;
  }
  .permisslist {
    margin-top: 45px;
  }
  .side-ios {
    margin-top: 65px;
  }
  .enquiries {
    height: 44px;
    background-color: rgb(244,244,244);
    position: relative;
    padding: 1rem 1.2rem;
  }
  .enquiries input {
    background-color: #fff;
    margin: 0;
    padding: 0 0 0 3rem;
    border-radius: 5px;
  }
  .archieve_img {
    position: absolute;
    width: 4.3%;
    left: 6%;
    top: 39%;
  }
  .permibox {
    font-size: 1.4rem;
    background-color: #fff;
    position: fixed;
    width: 100%;
    left: 0;
    bottom: 0;
    top: 113px;
    height: auto;
    overflow: auto;
  }
  
.permibox::-webkit-scrollbar {
  display: none;
}

  .permibox li {
    /* padding: 1.2rem; */
    overflow: hidden;
    padding: 0 1.2rem;
  }
  .permibox div {
    float: left;
    height: 4.4rem;
    line-height: 4.4rem;
  }
  .permibox .edits {
    float: right;
    color: #FF790E;
  }
  .permibox .edits i {
    display: inline-block;
    width: 1rem;
    height: 1.6rem;
    background: url('../../../assets/img/center/right-icon.png') no-repeat;
    background-size: 1rem 1.6rem;
    position: relative;
    top: 5px;
  }
  .permibox .edits span {
    margin-right: 1rem;
  }
  .permintime {
    width: 50%;
    text-align: center;
    color: #808080;
  }
  .perminame {
    font-size: 1.4rem;
    width: 25%;
  }
  .enquiries input {
    float: left;
    width: 85%;
  }
  .seachtn {
    font-size: 1.4rem;
    float: right;
    width: 10%;
    text-align: center;
    height: 44px;
    line-height: 44px;
    color: #FF790E;
  }


  .site-header {
    height: 45px;
    line-height: 45px;
    background: #fff;
    border-bottom: 1px solid #dedede;
  }
  .site-header .go-back {
    float: left;
    width: 14.06%;
    height: 45px;
    font-size: 14px;
    color: #212121;
  }
  .site-header .go-back i {
    display: block;
    width: 16px;
    height: 16px;
    margin-top: 15px;
    margin-left: 15px;
    background-image: url(../../../assets/img/arrow-l.png);
    background-repeat: no-repeat;
    -webkit-background-size: contain;
    background-size: contain;
  }

  .site-header h1 {
    margin-left: 14.06%;
    margin-right: 14.06%;
    font-size: 18px;
    text-align: center;
    margin-bottom: 0;
    margin-top: 0;
    font-weight: normal;
  }

  .go-new {
    float: right !important;
    color: #212121 !important;
    text-align: center;
  }
  .side-fixed {
    width: 100%;
    position: fixed;
    top: 0;
    z-index: 999;
  }
  .side-fixd-ios {
    width: 100%;
    position: fixed;
    top: 20px;
    z-index: 999;
  }
  @media screen and (max-width: 320px) {
    .go-new {
      width: 22% !important;
    }
  }

  @media screen and (min-width: 320px) and (max-width: 400px) {
    .go-new {
      width: 20% !important;
    }
  }

</style>
<script>
import kHeader from '../../common/head'
import util from '../../../libs/util'
import { formatDate } from '../../../libs/time'
export default {
  name: 'setpermissions',
  data() {
    return {
      permisli: '',
      seachname: '',
      headIos: false
    }
  },
  components: {
    kHeader
  },
  methods: {
    getpermis() {
      var that = this;
      var url = 'lblsapp-h5/v2/personCenter/assignPermissions.json';
      util.ajax.post(url).then(function(stats){
        console.log(stats.data.res.data);
        that.permisli = stats.data.res.data;
      }).catch(function(error){
        console.log(error);
      })
    },
    seachnames() {
      var that = this;
      var url = 'lblsapp-h5/v2/personCenter/queryAdminByName.json';
      var names = {};
      names.name = that.seachname;
      console.log(names);
      util.ajax.post(url, names).then(function(stats){
        that.permisli = stats.data.res.data;
      }).catch(function(error){
        console.log(error);
      })
    },
    edits(k) {
      this.$router.push({ path: '/editWarden', query: { id: k } });
    },
    ump() {
      this.$router.push('/addWarden')
    },
    goBack() {
      this.$router.push('/center');
    }
  },
  created() {
    if (window.navigator.userAgent.indexOf('LBLSIOS') > -1) {
      this.headIos = true;
    }
    this.getpermis();
  },
  filters: {
    fromdate(times) {
      var date = new Date(times);
      return formatDate(date, 'yyyy-MM-dd');
    }
  }
}
</script>

